export function setMicrophonePermissions() {
	let lang = getApp().globalData.lang;
	var let_title = lang == 'zh' ? '麦克风权限开启提醒' : 'Microphone Permission Reminder';
	var let_content = lang == 'zh' ? '您还没有开启麦克风权限，无法使用语音功能，请前往设置！' : 'You have not enabled microphone permissions, which prevents the use of voice features. Please go to settings!';
	var let_btn = lang == 'zh' ? '去设置' : 'Go to Settings';
	var let_btn2 = lang == 'zh' ? '暂不' : 'Not Now';

	// #ifdef APP-PLUS 
	if (plus.os.name == 'Android') {
		var main = plus.android.runtimeMainActivity();
		var permissions = plus.android.importClass("android.Manifest.permission");
		var isGranted = plus.android.invoke('android.support.v4.content.ContextCompat', 'checkSelfPermission', main, permissions.RECORD_AUDIO);
		
		if (isGranted !== 0) { // 0 indicates permission granted
			uni.showModal({
				title: let_title,
				content: let_content,
				showCancel: true,
				confirmText: let_btn,
				confirmColor: '#36d',
				cancelText: let_btn2,
				cancelColor: '#999',
				success: function(res) {
					if (res.confirm) {
						var Intent = plus.android.importClass('android.content.Intent');
						var settingsIntent = new Intent('android.settings.APPLICATION_DETAILS_SETTINGS');
						var uri = plus.android.importClass('android.net.Uri').fromParts("package", main.getPackageName(), null);
						settingsIntent.setData(uri);
						main.startActivity(settingsIntent);
					}
				}
			});
		}
	} else if (plus.os.name == 'iOS') {
		var isOn = plus.ios.invoke('AVAudioSession', 'sharedInstance');
		if (!isOn) {
			uni.showModal({
				title: let_title,
				content: let_content,
				showCancel: true,
				confirmText: let_btn,
				confirmColor: '#36d',
				cancelText: let_btn2,
				success: function(res) {
					if (res.confirm) {
						var app = plus.ios.invoke('UIApplication', 'sharedApplication');
						var setting = plus.ios.invoke('NSURL', 'URLWithString:', 'app-settings:');
						plus.ios.invoke(app, 'openURL:', setting);
					}
				}
			});
		}
	}
	// #endif 
}
